/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author PR
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasMesDevice extends BasicModel<BasMesDevice> {
  code?: string; // 设备号
  name?: string; // 名称
  dbNo?: string; // 电表号
  sort?: number; // 顺序号
  minVal?: number; // 最小值
  maxVal?: number; // 最大值
  lineCode?: string; // 生产线
  createByName?: string; // 创建人
}

export const basMesDeviceList = (params?: BasMesDevice | any) =>
  defHttp.get<BasMesDevice>({ url: adminPath + '/bas/mes/dev/basMesDevice/list', params });

export const basMesDeviceListData = (params?: BasMesDevice | any) =>
  defHttp.post<Page<BasMesDevice>>({ url: adminPath + '/bas/mes/dev/basMesDevice/listData', params });

export const basMesDeviceForm = (params?: BasMesDevice | any) =>
  defHttp.get<BasMesDevice>({ url: adminPath + '/bas/mes/dev/basMesDevice/form', params });

export const basMesDeviceSave = (params?: any, data?: BasMesDevice | any) =>
  defHttp.postJson<BasMesDevice>({ url: adminPath + '/bas/mes/dev/basMesDevice/save', params, data });

export const basMesDeviceImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/mes/dev/basMesDevice/importData',
      onUploadProgress,
    },
    params,
  );

export const basMesDeviceDelete = (params?: BasMesDevice | any) =>
  defHttp.get<BasMesDevice>({ url: adminPath + '/bas/mes/dev/basMesDevice/delete', params });
